<%@ page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="utf-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="lg"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="lg2"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link rel="stylesheet"
	href="${pageContext.request.contextPath}/static/css/bootstrap.min.css">
<link rel="stylesheet"
	href="${pageContext.request.contextPath}/static/css/font.css">
<link rel="stylesheet"
	href="${pageContext.request.contextPath}/static/css/xadmin.css">
<script type="text/javascript"
	src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>
<script type="text/javascript"
	src="${pageContext.request.contextPath}/static/lib/layui/layui.js"
	charset="utf-8">
</script>
<script type="text/javascript"
	src="${pageContext.request.contextPath}/static/js/xadmin.js"></script>
<script type="text/javascript"
	src="${pageContext.request.contextPath}/static/js/cookie.js"></script>
<!-- 让IE8/9支持媒体查询，从而兼容栅格 -->
<!--[if lt IE 9]>
      <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
      <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
</head>
  
  <body>
    <div class="x-nav">
      <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right" href="javascript:location.replace(location.href);" title="刷新">
        刷新</a>
    </div>
    <!--查询  -->
    <!-- 查询条件 -->
	<div class="x-body">
		<div class="layui-row">
			<form class="layui-form layui-col-md12 x-so" action="${pageContext.request.contextPath}/rewards/rewardsList"
		method="post"> 
				<div class="layui-input-inline">
					<select name="serch_id" lay-verify=""
						style="width: 150px; position: right">
						<option value="">请选择一个员工</option>
						<lg:forEach items="${staffList}" var="staff">
							<option value="${staff.id}"
								>${staff.staff_name}
							</option>
						</lg:forEach>
					</select>
				</div>
				<button class="layui-btn" lay-submit="" lay-filter="sreach">
					<i class="layui-icon">&#xe615;</i>
				</button>
			</form>
		</div>
      
      
      
      
      
      <xblock>
      <a type="button" class="layui-btn" href="${pageContext.request.contextPath}/rewards/addWho">
			<i class="layui-icon"></i>添加
		</a>
        <button class="layui-btn layui-btn-danger" onclick="delAll()"><i class="layui-icon"></i>批量删除</button>
        	        <span class="x-right" style="line-height:40px">总共有${lg2:length(rewards.list)}条数据 </span>  
        
      </xblock> 
      <table class="layui-table x-admin">
        <thead>
          <tr>
            <th>
              <div class="layui-unselect header layui-form-checkbox" lay-skin="primary"><i class="layui-icon">&#xe605;</i></div>
            </th>
            
            <th>人员名称</th>
            <th>奖惩类型</th>
            <th>奖惩日期</th>
            <th>奖惩理由</th>
            <th>奖惩内容</th>
            <th>操作</th>
            </tr>
        </thead>
        <tbody>
        <lg:forEach items="${rewards.list}" var="m">
			<tr>
			<td><div class="layui-unselect layui-form-checkbox"
								lay-skin="primary" data-id='${m.randp_id}'>
								<i class="layui-icon">&#xe605;</i>
							</div></td>
						<td style="display: none">${m.randp_id}</td>
						<td>${m.staff.staff_name}</td>
				<td>${m.type}</td>
				<td><fmt:formatDate value="${m.date}"/></td>
				<td>${m.reason}</td>
				<td>${m.content}</td>
				<td><a title="编辑"
							href="${pageContext.request.contextPath}/rewards/updateOne?cid=${m.randp_id}"><i
								class="layui-icon">&#xe642;</i> </a>
	              
	            
	               <a href="${pageContext.request.contextPath}/rewards/delRewards?id=${m.randp_id}">
		                <i class="layui-icon">&#xe640;</i>
		              </a>
	             
	            </td>
			</tr>
		</lg:forEach>
        </tbody>
      </table>
      <div class="page">
        <div>
          <a class="prev" href="${pageContext.request.contextPath}/rewards/rewardsList?startPage=${rewards.prePage}&PageSize=${rewards.pageSize}">&lt;&lt;</a> 
          <a class="num" href="${pageContext.request.contextPath}/rewards/rewardsList?startPage=1&PageSize=${rewardsjiang.pageSize}">首页</a>
          <lg:forEach items="${rewards.navigatepageNums}" var="na">
          	<lg:if test="${na==rewards.pageNum}">
         		<a class="num" href="${pageContext.request.contextPath}/rewards/rewardsList?startPage=${na}&PageSize=${rewards.pageSize}"  style="color:red;font-size=16px">${na}</a>
        	</lg:if>
        	<lg:if test="${na!=rewards.pageNum}">
        		<a class="num" href="${pageContext.request.contextPath}/rewards/rewardsList?startPage=${na}&PageSize=${rewards.pageSize}"  >${na}</a>
        	</lg:if>
          </lg:forEach>
          <a class="num" href="${pageContext.request.contextPath}/rewards/rewardsList?startPage=${rewards.pages}&PageSize=${rewards.pageSize}">尾页</a>
          <a class="prev" href="${pageContext.request.contextPath}/rewards/rewardsList?startPage=${rewards.nextPage}&PageSize=${rewards.pageSize}">&gt;&gt;</a> 
          <%-- <lg:forEach end="${staff.total}" begin="1" var="n">
           	<a class="num" href="${pageContext.request.contextPath}/record/recordList?startPage=${na}">${na}</a>
          </lg:forEach> --%>
          <span><form action="${pageContext.request.contextPath}/rewards/rewardsList" method="post" >
	         输入展示数量<input type="text" placeholder="输入展示数量" name="PageSize" value="${rewards.pageSize}" style="width:30px;text-align:center"/>
	         <input value="刷新" class="glyphicon glyphicon-refresh" type="submit"/>
          </form></span>
        </div>


    </div>
   
    <script>
    $("#add_rewards").click(function() {
		$.ajax({
			url : "addRewards",
			type : "post",
			async : true,
			data : $("#add_form").serialize(),
			error : function() {
			},
			success : function(data) {
				$('#addModal').modal('hide');
				location.href="${pageContext.request.contextPath}/rewards/rewardsList";
			}
		});
	});
    	
    
      layui.use('laydate', function(){
        var laydate = layui.laydate;
        
        //执行一个laydate实例
        laydate.render({
          elem: '#start' //指定元素
        });

        //执行一个laydate实例
        laydate.render({
          elem: '#end' //指定元素
        });
      });

       /*用户-停用*/
      function member_stop(obj,id){
          layer.confirm('确认要停用吗？',function(index){

              if($(obj).attr('title')=='启用'){

                //发异步把用户状态进行更改
                $(obj).attr('title','停用')
                $(obj).find('i').html('&#xe62f;');

                $(obj).parents("tr").find(".td-status").find('span').addClass('layui-btn-disabled').html('已停用');
                layer.msg('已停用!',{icon: 5,time:1000});

              }else{
                $(obj).attr('title','启用')
                $(obj).find('i').html('&#xe601;');

                $(obj).parents("tr").find(".td-status").find('span').removeClass('layui-btn-disabled').html('已启用');
                layer.msg('已启用!',{icon: 5,time:1000});
              }
              
          });
      }

      /*用户-删除*/
      function member_del(obj,id){
          layer.confirm('确认要删除吗？',function(index){
              //发异步删除数据
              $(obj).parents("tr").remove();
              layer.msg('已删除!',{icon:1,time:1000});
          });
      }



      function delAll(argument) {
			layer.confirm('确认要删除吗？',
				function() {
					var ids = tableCheck.getData();
					$.ajax({
						url : "${pageContext.request.contextPath}/rewards/deleteMany",
						type : "post",
						data : {
							"ids" : ids.join(",")
						},
						error : function() {
						},
						success : function(data) {
							if (data) {
								layer.msg('删除任务成功', {
									icon : 1,
									zIndex : 66,
								});
								$(".layui-form-checked")
										.not('.header')
										.parents('tr')
										.remove();
							} else {
								layer.msg('删除失败');

							}

						}

					});					

			});

		}
    </script>
    <script>var _hmt = _hmt || []; (function() {
        var hm = document.createElement("script");
        hm.src = "https://hm.baidu.com/hm.js?b393d153aeb26b46e9431fabaf0f6190";
        var s = document.getElementsByTagName("script")[0];
        s.parentNode.insertBefore(hm, s);
      })();</script>
      <script type="text/javascript"
		src="${pageContext.request.contextPath}/static/js/jquery-1.12.3.min.js"></script>
	<script type="text/javascript"
		src="${pageContext.request.contextPath}/static/js/bootstrap.min.js"></script>
  </body>
</html>